fix icon colors for macos#1579
Merged
richiemcilroy merged 1 commit intoCapSoftware:mainfrom Feb 4, 2026
Merged
Conversation
|
|
||
| if let Ok(icon) = Image::from_bytes(get_mode_icon(mode)) { | ||
| let _ = tray.set_icon(Some(icon)); | ||
| let _ = tray.set_icon_as_template(true); |
There was a problem hiding this comment.
Should we gate template mode to macOS for consistency with .icon_as_template(cfg!(target_os = "macos"))? If set_icon_as_template(true) isn’t a no-op on Linux, it could affect icon colors.
Suggested change
| let _ = tray.set_icon_as_template(true); | |
| let _ = tray.set_icon_as_template(cfg!(target_os = "macos")); |
Member
|
Lovely! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The icon tray menu colors on macOS weren't responding to dark/light mode. They were displaying white on a white background. This PR updates the project to use dynamically colored tray icons for the menu bar using the macOS template API. Should work with windows and linux too since they use
tray-default-icon.png. Uses the same solution that my https://github.com/josiahsrc/voquill project uses.Greptile Overview
Greptile Summary
This PR fixes tray icon visibility issues on macOS by enabling template icon mode, which allows the system to automatically adapt icon colors based on the current theme (light/dark mode).
Changes Made:
set_icon_as_template(true)calls in four locations where tray icons are updated (tray.rs:630,tray.rs:892,tray.rs:914)icon_as_template(cfg!(target_os = "macos"))during initial tray creation (tray.rs:664)Technical Implementation:
The fix uses the macOS template icon API, which requires icons to be monochrome (black with transparency). The system then inverts and adjusts these icons based on the menu bar appearance. The implementation correctly:
cfg!(target_os = "macos")cfg!(target_os = "windows")guards)Cross-platform Compatibility:
Windows and Linux continue using
tray-default-icon.png(unchanged) and don't callset_icon_as_template, so this change is macOS-specific with no impact on other platforms.Confidence Score: 5/5
Important Files Changed
set_icon_as_template(true)calls to enable macOS template icon rendering for proper dark/light mode supportSequence Diagram
sequenceDiagram participant App as AppHandle participant Tray as TrayIcon participant System as macOS System participant User as User Display Note over App,User: Tray Icon Initialization (create_tray) App->>Tray: TrayIconBuilder::with_id("tray") App->>Tray: .icon(initial_icon) App->>Tray: .icon_as_template(cfg!(target_os = "macos")) Note over Tray,System: Template flag set for macOS only Tray->>System: Register tray icon with template mode System->>User: Display icon (adapts to light/dark mode) Note over App,User: Mode Change (update_tray_icon_for_mode) App->>Tray: set_icon(Some(icon)) App->>Tray: set_icon_as_template(true) System->>User: Update icon display (maintains theme adaptation) Note over App,User: Recording Started Event App->>Tray: set_icon(stop_icon) App->>Tray: set_icon_as_template(true) System->>User: Show stop icon (adapts to light/dark mode) Note over App,User: Recording Stopped Event App->>Tray: set_icon(mode_icon) App->>Tray: set_icon_as_template(true) System->>User: Restore mode icon (adapts to light/dark mode)(2/5) Greptile learns from your feedback when you react with thumbs up/down!